
rootDir=/nat-ddns
version="0.37.1"
frpDownloadUrl=https://github.com/fatedier/frp/releases/download/v${version}/frp_${version}_linux_amd64.tar.gz
frpZipName=frp_${version}_linux_amd64.tar.gz
frpPrefixName=frp_${version}_linux_amd64


fn_install(){
    mkdir -p $rootDir
    wget $frpDownloadUrl -P $rootDir

    cd /nat-ddns
    tar zxvf $frpZipName
    cd $frpPrefixName
    # mv frp_0.34.0_linux_amd64 frp
    # cd frp

#     read -p "Please input vhost_http_port(7001): " vhost_http_port
#     if [ -z "$vhost_http_port" ];then
#         vhost_http_port="7001"
#     fi

# #todo 换行问题
#     iniContent="[common]\nbind_port = 7000\nvhost_http_port = $vhost_http_port"

#     echo -e "\t" "frps.ini:"
#     echo -e $iniContent
    

#     echo -e $iniContent > ./frps.ini

    # cp $bootDir/frps.sh /usr/bin/frps

    # wget https://gitee.com/buyili/nat-ddns/raw/master/frp/frps_init.ini -O frps.ini
    # wget https://gitee.com/buyili/nat-ddns/raw/master/frp/frps.sh -P /usr/bin/frps
    # chmod +777 /usr/bin/frps


    mkdir -p /etc/frp
    wget https://gitee.com/buyili/nat-ddns/raw/master/frp/frps_init.ini -O /etc/frp/frps.ini
    cp ./frps /usr/bin/frps
    cp systemd/frps.service /lib/systemd/system
    systemctl enable frps
}

fn_install